package jeecg.business.entity.keyinfo;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import jeecg.business.vo.ContainWordNum;
import jodd.util.StringUtil;

import org.hibernate.annotations.GenericGenerator;
import org.jeecgframework.core.util.clean.bean.HtmlParseResult;
import org.jeecgframework.core.util.wordseg.MmSegment;

/**   
 * @Title: Entity
 * @Description: 舆情信息
 * @author LinYingPiaoJian
 * @date 2015-06-06 16:50:42
 * @version V1.0   
 *
 */
@Entity
@Table(name = "NMS_KEY_INFO", schema = "")
@SuppressWarnings("serial")
public class KeyinfoEntity implements java.io.Serializable , Cloneable{
	/**主键*/
	private java.lang.String id;
	/**标题*/
	private java.lang.String title;
	/**采集内容*/
	private java.lang.String bodycontent;
	/**关键字*/
	private java.lang.String keyword;
	
	private String allkeyword;
	/**
	 * 相关词汇
	 */
	private String refword;
	/**
	 * 相关词汇次数
	 */
	private String refwordnum;
	/**采集站点*/
	private java.lang.String cjzd;
	/**站点URL*/
	private java.lang.String site;
	/**来源*/
	private java.lang.String ly;
	/**类型*/
	private java.lang.String type;
	/**报警时间*/
	private java.util.Date eventdate;
	/**源URL*/
	private java.lang.String yurl;
	/**IP*/
	private java.lang.String ip;
	/**CDN地址*/
	private java.lang.String address;
	/**省份*/
	private java.lang.String sf;
	/**作者*/
	private java.lang.String zz;
	/**摘要*/
	private java.lang.String zy;
	/**负面值*/
	private java.lang.Float fmz;
	/**
	 * 负面词
	 */
	private String fmc;
	/**
	 * 信息类型	-1-正面	0-无		1-轻度	2-中度	3-严重
	 */
	private String fmjb;
	/**
	 * 警戒词次数
	 */
	private String fmccs;
	/**
	 * 是否预警
	 */
	private String sfyj;
	/**
	 * 是否负面
	 */
	private String sffm;
	/**
	 * 是否疑似
	 */
	private String sfys;
	/**
	 * 企业ID
	 */
	private String qyid;
	/**
	 * 是否删除
	 */
	private String sfsc;
	/**
	 * 是否简报
	 */
	private String sfjb;
	/**
	 * 简报时间
	 */
	private Date jbsj;
	/**
	 * 采集时间
	 */
	private Date cjsj;
	/**
	 * 是否手工
	 */
	private String sfsg;
	
	/******************assist*************/
	
	private String stitle;
	
	private String mtitle;
	
	private String ltitle;
	
	private String sbody;
	
	private String syurl;
	/**
	 * 关键字标题
	 */
	private String rstitle;
	
	private String rmtitle;
	
	private String rltitle;
	
	public static String PRE_RED = "<font color=\"red\">";
	public static String END_RED = "</font>";
	
	
	private String starttime;
	
	private String endtime;
	
	private String querycontent;
	
	private String pcfs;
	
	private String keywordtype;
	
	private String typename;
	
	private KeyinfoTextEntity text;
	
	private String refwordtext;
	
	private List<ContainWordNum> wordNumList;
	
	
	@Transient
	public List<ContainWordNum> getWordNumList(){
		return wordNumList;
	}

	public void setWordNumList(List<ContainWordNum> wordNumList) {
		this.wordNumList = wordNumList;
	}

	@Transient
	public String getRefwordtext() {
		String t = "";
		if(StringUtil.isEmpty(refword)) return "";
		String [] refwords = refword.split("\\|");
		String [] nums = refwordnum.split("\\|");
		for(int i=0;i<refwords.length;i++)
			t += refwords[i]+"("+nums[i]+")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		refwordtext = t;
		return refwordtext;
	}

	public void setRefwordtext(String refwordtext) {
		this.refwordtext = refwordtext;
	}

	@Transient
	public KeyinfoTextEntity getText() {
		return text;
	}

	public void setText(KeyinfoTextEntity text) {
		this.text = text;
	}

	@Transient
	public String getTypename() {
		return typename;
	}

	public void setTypename(String typename) {
		this.typename = typename;
	}

	@Transient
	public String getKeywordtype() {
		return keywordtype;
	}

	public void setKeywordtype(String keywordtype) {
		this.keywordtype = keywordtype;
	}

	@Transient
	public String getPcfs() {
		return pcfs;
	}

	public void setPcfs(String pcfs) {
		this.pcfs = pcfs;
	}

	@Transient
	public String getQuerycontent() {
		return querycontent;
	}

	public void setQuerycontent(String querycontent) {
		this.querycontent = querycontent;
	}

	@Transient
	public String getStarttime() {
		return starttime;
	}

	public void setStarttime(String starttime) {
		this.starttime = starttime;
	}
	@Transient
	public String getEndtime() {
		return endtime;
	}

	public void setEndtime(String endtime) {
		this.endtime = endtime;
	}

	@Transient
	public String getRmtitle() {
		mtitle = getMtitle();
		try {
			rmtitle = mtitle;
			List<String> klist = MmSegment.segment(allkeyword);
			if(klist != null){
				for(String k : klist)
					rmtitle = rmtitle.replace(k, PRE_RED+k+END_RED);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return rmtitle;
	}

	public void setRmtitle(String rmtitle) {
		this.rmtitle = rmtitle;
	}
	@Transient
	public String getRltitle() {
		ltitle = getLtitle();
		try {
			rltitle = ltitle;
			List<String> klist = MmSegment.segment(allkeyword);
			if(klist != null){
				for(String k : klist)
					rltitle = rltitle.replace(k, PRE_RED+k+END_RED);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return rltitle;
	}

	public void setRltitle(String rltitle) {
		this.rltitle = rltitle;
	}

	@Transient
	public String getRstitle() {
		stitle = getStitle();
		try {
			rstitle = stitle;
			List<String> klist = MmSegment.segment(allkeyword);
			if(klist != null){
				for(String k : klist)
					rstitle = rstitle.replace(k, PRE_RED+k+END_RED);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return rstitle;
	}

	public void setRstitle(String rstitle) {
		this.rstitle = rstitle;
	}

	@Override
	public KeyinfoEntity clone(){
		try {
			return (KeyinfoEntity)super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	@Transient
	public String getSyurl() {
		if(StringUtil.isNotBlank(yurl)){
			if(yurl.length()>=30)
				syurl = yurl.substring(0,29)+"...";
			else
				syurl = yurl;
		}
		return syurl;
	}

	public void setSyurl(String syurl) {
		this.syurl = syurl;
	}

	@Transient
	public String getSbody() {
		if(StringUtil.isNotBlank(bodycontent)){
			if(bodycontent.length()>=50)
				sbody = bodycontent.substring(0,49);
			else
				sbody = bodycontent;
		}
		return sbody;
	}

	public void setSbody(String sbody) {
		this.sbody = sbody;
	}
	
	@Transient
	public String getLtitle() {
		if(StringUtil.isNotBlank(title)){
			if(title.length()>=50)
				ltitle = title.substring(0,49);
			else
				ltitle = title;
		}
		return ltitle;
	}

	public void setLtitle(String ltitle) {
		this.ltitle = ltitle;
	}

	@Transient
	public String getMtitle() {
		if(StringUtil.isNotBlank(title)){
			if(title.length()>=28)
				mtitle = title.substring(0,27);
			else
				mtitle = title;
		}
		return mtitle;
	}

	public void setMtitle(String mtitle) {
		this.mtitle = mtitle;
	}

	@Transient
	public String getStitle(){
		if(StringUtil.isNotBlank(title)){
			if(title.length()>=21)
				stitle = title.substring(0,20);
			else
				stitle = title;
		}
		return stitle;
	}

	public void setStitle(String stitle) {
		this.stitle = stitle;
	}

	public KeyinfoEntity(){}
	
	public KeyinfoEntity(HtmlParseResult result){
		this.title = result.getTitle();
		this.bodycontent = result.getBodycontent();
		this.keyword = result.getKeyword();
		this.cjzd = result.getCjzd();
		this.site = result.getSite();
		this.ly = result.getLy();
		this.type = result.getType();
		this.pcfs = result.getPcfs();
		this.yurl = result.getUrl();
		this.ip = result.getIp();
		this.address = result.getAddress();
		this.sf = result.getSf();
		this.zz = result.getZz();
		this.zy = result.getZy();
		
		if(result.getEventDate() == null)
			this.eventdate = new Date();
		else
		this.eventdate = result.getEventDate();
		
		if(this.eventdate.getTime() > System.currentTimeMillis())this.eventdate = new Date();
		
		this.cjsj = new Date();
	}
	
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  主键
	 */
	
	@Id
	@GeneratedValue(generator = "paymentableGenerator")
	@GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
	@Column(name ="ID",nullable=false,length=32)
	public java.lang.String getId(){
		return this.id;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  主键
	 */
	public void setId(java.lang.String id){
		this.id = id;
	}
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  标题
	 */
	@Column(name ="TITLE",nullable=true,length=255)
	public java.lang.String getTitle(){
		return this.title;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  标题
	 */
	public void setTitle(java.lang.String title){
		this.title = title;
	}
	/**
	 *方法: 取得java.lang.Object
	 *@return: java.lang.Object  采集内容
	 */
//	@Column(name ="BODYCONTENT",nullable=true,length=65535)
	@Transient
	public java.lang.String getBodycontent(){
		return this.bodycontent;
	}

	/**
	 *方法: 设置java.lang.Object
	 *@param: java.lang.Object  采集内容
	 */
	public void setBodycontent(java.lang.String bodycontent){
		this.bodycontent = bodycontent;
	}
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  关键字
	 */
	@Column(name ="KEYWORD",nullable=true,length=255)
	public java.lang.String getKeyword(){
		return this.keyword;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  关键字
	 */
	public void setKeyword(java.lang.String keyword){
		this.keyword = keyword;
	}
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  采集站点
	 */
	@Column(name ="CJZD",nullable=true,length=255)
	public java.lang.String getCjzd(){
		return this.cjzd;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  采集站点
	 */
	public void setCjzd(java.lang.String cjzd){
		this.cjzd = cjzd;
	}
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  站点URL
	 */
	@Column(name ="SITE",nullable=true,length=255)
	public java.lang.String getSite(){
		return this.site;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  站点URL
	 */
	public void setSite(java.lang.String site){
		this.site = site;
	}
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  来源
	 */
	@Column(name ="LY",nullable=true,length=255)
	public java.lang.String getLy(){
		return this.ly;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  来源
	 */
	public void setLy(java.lang.String ly){
		this.ly = ly;
	}
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  类型
	 */
	@Column(name ="TYPE",nullable=true,length=32)
	public java.lang.String getType(){
		return this.type;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  类型
	 */
	public void setType(java.lang.String type){
		this.type = type;
	}
	/**
	 *方法: 取得java.util.Date
	 *@return: java.util.Date  报警时间
	 */
	@Column(name ="EVENTDATE",nullable=true)
	public java.util.Date getEventdate(){
		return this.eventdate;
	}

	/**
	 *方法: 设置java.util.Date
	 *@param: java.util.Date  报警时间
	 */
	public void setEventdate(java.util.Date eventdate){
		this.eventdate = eventdate;
	}
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  源URL
	 */
	@Column(name ="YURL",nullable=true,length=255)
	public java.lang.String getYurl(){
		return this.yurl;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  源URL
	 */
	public void setYurl(java.lang.String yurl){
		this.yurl = yurl;
	}
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  IP
	 */
	@Column(name ="IP",nullable=true,length=31)
	public java.lang.String getIp(){
		return this.ip;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  IP
	 */
	public void setIp(java.lang.String ip){
		this.ip = ip;
	}
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  CDN地址
	 */
	@Column(name ="ADDRESS",nullable=true,length=255)
	public java.lang.String getAddress(){
		return this.address;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  CDN地址
	 */
	public void setAddress(java.lang.String address){
		this.address = address;
	}
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  省份
	 */
	@Column(name ="SF",nullable=true,length=31)
	public java.lang.String getSf(){
		return this.sf;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  省份
	 */
	public void setSf(java.lang.String sf){
		this.sf = sf;
	}
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  作者
	 */
	@Column(name ="ZZ",nullable=true,length=255)
	public java.lang.String getZz(){
		return this.zz;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  作者
	 */
	public void setZz(java.lang.String zz){
		this.zz = zz;
	}
	/**
	 *方法: 取得java.lang.String
	 *@return: java.lang.String  摘要
	 */
	@Column(name ="ZY",nullable=true,length=255)
	public java.lang.String getZy(){
		return this.zy;
	}

	/**
	 *方法: 设置java.lang.String
	 *@param: java.lang.String  摘要
	 */
	public void setZy(java.lang.String zy){
		this.zy = zy;
	}
	/**
	 *方法: 取得java.lang.Float
	 *@return: java.lang.Float  负面值
	 */
	@Column(name ="FMZ",nullable=true,precision=12)
	public java.lang.Float getFmz(){
		return this.fmz;
	}

	/**
	 *方法: 设置java.lang.Float
	 *@param: java.lang.Float  负面值
	 */
	public void setFmz(java.lang.Float fmz){
		this.fmz = fmz;
	}
	@Column(name ="FMC")
	public String getFmc() {
		return fmc;
	}

	public void setFmc(String fmc) {
		this.fmc = fmc;
	}
	@Column(name ="SFYJ")
	public String getSfyj() {
		return sfyj;
	}

	public void setSfyj(String sfyj) {
		this.sfyj = sfyj;
	}
	@Column(name ="SFFM")
	public String getSffm() {
		return sffm;
	}

	public void setSffm(String sffm) {
		this.sffm = sffm;
	}
	@Column(name ="SFYS")
	public String getSfys() {
		return sfys;
	}

	public void setSfys(String sfys) {
		this.sfys = sfys;
	}
	@Column(name ="QYID")
	public String getQyid() {
		return qyid;
	}

	public void setQyid(String qyid) {
		this.qyid = qyid;
	}
	@Column(name ="SFSC")
	public String getSfsc() {
		return sfsc;
	}

	public void setSfsc(String sfsc) {
		this.sfsc = sfsc;
	}
	@Column(name ="SFJB")
	public String getSfjb() {
		return sfjb;
	}

	public void setSfjb(String sfjb) {
		this.sfjb = sfjb;
	}
	@Column(name ="JBSJ")
	public Date getJbsj() {
		return jbsj;
	}

	public void setJbsj(Date jbsj) {
		this.jbsj = jbsj;
	}
	
	@Column(name ="CJSJ")
	public Date getCjsj() {
		return cjsj;
	}

	public void setCjsj(Date cjsj) {
		this.cjsj = cjsj;
	}
	@Column(name ="SFSG")
	public String getSfsg() {
		return sfsg;
	}

	public void setSfsg(String sfsg) {
		this.sfsg = sfsg;
	}
	@Column(name ="ALLKEYWORD")
	public String getAllkeyword() {
		return allkeyword;
	}

	public void setAllkeyword(String allkeyword) {
		this.allkeyword = allkeyword;
	}
	
	@Column(name ="REFWORD")
	public String getRefword() {
		return refword;
	}

	public void setRefword(String refword) {
		this.refword = refword;
	}
	
	@Column(name ="REFWORDNUM")
	public String getRefwordnum() {
		return refwordnum;
	}

	public void setRefwordnum(String refwordnum) {
		this.refwordnum = refwordnum;
	}
	@Column(name ="FMJB")
	public String getFmjb() {
		return fmjb;
	}

	public void setFmjb(String fmjb) {
		this.fmjb = fmjb;
	}
	@Column(name ="FMCCS")
	public String getFmccs() {
		return fmccs;
	}

	public void setFmccs(String fmccs) {
		this.fmccs = fmccs;
	}
	
	
}
